import 'package:flutter/material.dart';

class LoginInput extends StatelessWidget {
  LoginInput({
    super.key,
    required this.label,
    required this.hintText,
    required this.icon,
    required this.saveFunc,
    required this.validatorFunc,
    this.keyboardType,
    this.obscureText = false,
    this.initialValue,
  });

  final String label;
  final String hintText;
  final IconData? icon;
  final Function saveFunc;
  final Function validatorFunc;
  final String? initialValue;
  TextInputType? keyboardType = TextInputType.text;
  bool obscureText;

  @override
  Widget build(BuildContext context) {
    return TextFormField(
      initialValue: initialValue,
      keyboardType: keyboardType,
      obscureText: obscureText,
      decoration: InputDecoration(
        labelText: label,
        hintText: hintText,
        contentPadding: const EdgeInsets.all(15),
        border: const OutlineInputBorder(
          borderRadius: BorderRadius.all(Radius.circular(8)),
          borderSide: BorderSide(color: Colors.black12, width: 1),
        ),
        enabledBorder: const OutlineInputBorder(
          borderRadius: BorderRadius.all(Radius.circular(8)),
          borderSide: BorderSide(color: Colors.black12, width: 1),
        ),
        prefixIcon: Icon(icon),
      ),
      onSaved: (value) {
        saveFunc!(value);
      },
      validator: (String? value) {
        return validatorFunc(value);
      },
    );
  }
}
